package TextField
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class MenuTip extends Sprite
	{
		private var _text:String;
		private var _skin:Sprite;
		private var _defaultSkin:Sprite;
		
		private var _textField:TextField;
		public function MenuTip(label:String)
		{
			this._text = label;
			this.mouseEnabled = false;
			this.mouseChildren = false;
			super();
			init();
		}
		
		public function init():void {
			_textField = new TextField();
			_textField.text = _text;
			_textField.autoSize = "left";
			if(_textField.width>100) {
				_textField.width = 100;
				_textField.wordWrap = true;
			}
			
			_defaultSkin = new Sprite();
			_defaultSkin.graphics.beginFill(0x0,.5);
			_defaultSkin.graphics.drawRoundRect(-3,-1,_textField.width+6,_textField.height+2,20,20);
			_defaultSkin.graphics.endFill();
			
			installSkin();
		}
		
		public function installSkin():void {
			if(!_skin) {
				_skin = _defaultSkin;
			}
			
			_skin.addChild(_textField);
			this.addChild(_skin);
		}
		
		public function set text(t:String):void {
			this._text = t;
		}
		
		public function get text():String {
			return this._text;
		}
		
		public function set skin(s:Sprite):void {
			this.skin = s;
		}
	}
}